##!/usr/bin/python
## -*- coding: utf-8 -*-
#
#__date__ = u"30 mars 2010"
#__all__ = [u'LegacyParameters']
#
#import os
#
#from _pylot.core.datum import Datum
#from _pylot.core.book import Book
#from _pylot.core.parameterhandler import Parameters
#from _pylot.core.utils import Utils, uprint
#from datatypes import SimpleStringList
#
#class LegacyParameters (Parameters) :
#  u"""
#  Add methods readpyLotDatabase which read old pylotdb file format.
#  """
#  def readpyLotDatabase(self, filin):
#    u"""
#    Lecture au format pylot :
#    //Block machin
#    X 1. 2.1 7.0
#    Y initial final inter
#
#    //Block truc
#    Int 0 2 10
#    eps 1.0e-4 1.0e-6
#    vect 1 2 3 @ 4 5 6
#    """
#    if type(filin) == file : #fichier
#      lines = filin.readlines()
#    elif isinstance(filin, unicode) and os.path.isfile(filin): #Nom de fichier
#      lines = Utils.readfile(filin).readlines()
#    else :
#      lines = filin#Les lignes elles-même
#
#    block_name = u""
#    i = -1
#    for line in lines:
#      if len(line.strip()) == 0 or line[0] == u'#':
#        continue
#
#      words = line.split()
#      if words[0].strip().lower() == u'//block':#un bloc
#        i += 1
#        bloc = words[1]
#        try : self[bloc]
#        except : self[bloc] = Book(title=bloc)
#      elif (len(words) >= 1):#un paramètre et ses valeurs
#        params = ' '.join(words[1:]) #remove param name
#        try : self[bloc]
#        except UnboundLocalError :
#          uprint(tr_(u"Parameters.readpyLotDatabase(), malformed database file, \nforgetting line '%s'") % (line))
#        else:
#          if len(line.strip().split(u"@")) > 1:
#            nature = SimpleStringList
#            params = params.split(u'@')
#          else :
#            nature = unicode
#            params = params.split()
#          params = [val.strip() for val in params if val.strip()]
#          param = words[0].strip()
#          try : self[bloc][param]
#          except :
#            self[bloc][param] = Datum(name=param, nature=nature, value=None,
#                                      value_list=[], group=bloc)
#          try :
#            words[1]
#          except IndexError :
#            uprint(tr_(u"### Parameters.readpyLotDatabase, parameter without value : '%s' ==> I keep it") % line.strip())
#          else:
#            for value in params:
#              self[bloc][param].value = value # remplissage de value remplit aussi value_list
#            self[bloc][param].value = params[0]
